using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using System.Windows.Forms;

namespace p301.BO.ZhurnalObrasch.PrintRaspis
{
    public partial class PrintRaspis : DevExpress.XtraReports.UI.XtraReport
    {
        public PrintRaspis()
        {
            InitializeComponent();
        }

        public void Open(dsRazpis _dsRazpis)
        {
            this.DataSource = _dsRazpis;
            this.ShowPreview();
        }

        private void _dateBeginWeek_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            DateTime firtsYearDate = new DateTime(int.Parse(_YEAR_KONS.Text), 1, 1);
            int firtsYareDayofWeek = firtsYearDate.DayOfWeek == DayOfWeek.Sunday ? 7 : (int)firtsYearDate.DayOfWeek;
            DateTime beginYearDate = firtsYearDate.AddDays((int.Parse(_C_WEEK.Text) - 1) * 7 - (firtsYareDayofWeek - 1));
            _dateBeginWeek.Text = beginYearDate.ToShortDateString(); ;
        }
    }
}
